<!DOCTYPE html>
<html lang="en">
<head>
	<meta content="width=device-width,initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
	<meta name="apple-mobile-web-app-capable" content="no" />
	<link rel="shortcut icon" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/img/logo.png"/>
	<meta charset="UTF-8">
	<title>{{.title}}</title>
	<style type="text/css"></style>
	<script type="text/javascript" src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/mui/js/mui.min.js"></script>
	<link rel="stylesheet" type="text/css" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/mui/css/mui.min.css">
	<link rel="stylesheet" type="text/css" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/css/address.css?v=1">
	<link rel="stylesheet" type="text/css" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/css/other/all.css">
	<link rel="stylesheet" type="text/css" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/sui/css/SUI.css">
	<link rel="stylesheet" type="text/css" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/font/iconfont.css">
</head>
<style>
	.noaddress{height: calc(100vh - 50px);background: url('/static/wechat/img/noaddress.png') no-repeat;background-size: 40%;background-position: center;}
</style>
<body>
	<div style="padding-bottom: 60px;">
	{{if .info}}
	{{range .info}}
	<div class="address" id="{{.id}}">
	  <div class="auto">
	    <span class="fl">{{.name}}</span>
	    <span class="fr">{{.mobile}}</span>
	  </div>
	  <div>{{.shen}} {{.shi}} {{.qu}} {{.address}}</div>
	  <div class="auto">
	    <span class="fl icon {{if eq .default "0"}}defaults{{else}}chose{{end}}" data-id="{{.id}}">默认地址</span>
	    <span class="fr edit goto" href="/mobile/my/address_edit?id={{.id}}">编辑</span>
	    <span class="fr del" data-id="{{.id}}">删除</span>
	  </div>
	</div>
	{{end}}
	{{else}}
	<div class="noaddress"></div>
	{{end}}
	</div>
	<!-- <dl class="suiNotfound">
		<dt class="suiBgImg" style="background-image: url(/static/img/addressnone.png);"></dt>
		<dd>没有收货地址</dd>
	</dl> -->
	<!-- <div id="address"></div> -->
<div class="suiInBotButt goto" href="/mobile/my/address_add">添加地址</div>
</body>
{{template "wechat/public/share.html" .}}
<script type="text/javascript" src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/sui/js/SUI.js"></script>
<script type="text/javascript">
	mui('body').on('tap','.del',function(){
		this.disabled=true
		var that=this
		mui.confirm("您确定要删除该收货地址吗?","提示",function(data){
			if(data.index){
				mui.closePopups()
				var id=that.getAttribute("data-id")
				mui.ajax('/mobile/del',{
					data:{id:id,table:"mt_member_address"},
					timeout:10000,
					success:function(res){
						if(res){
							var del=document.getElementById(id)
							del.parentNode.removeChild(del)
							mui.toast("删除成功")
						}else{
							mui.alert("网络繁忙,请重试","提示")
						}
						that.disabled=false
					},error:function(){
						mui.alert("网络繁忙,请重试","提示")
						that.disabled=false
					}
				})
			}else{
				that.disabled=false
			}
		})
	})
	mui('body').on('tap','.icon',function(){
		this.disabled=true
		var that=this
		mui.confirm("您确定要设置为默认地址吗?","提示",function(data){
			if(data.index){
				var id=that.getAttribute("data-id")
				mui.ajax(window.location.href,{
					data:{id:id},
					timeout:10000,
					type:'post',
					success:function(res){
						if(res){
						var icon=document.getElementsByClassName("icon")
							for (var i=0;i<icon.length;i++){
								var id2=icon[i].getAttribute("data-id")
								if (id==id2){
									icon[i].setAttribute("class", "fl icon chose")
								}else{
									icon[i].setAttribute("class", "fl icon defaults")
								}
							}
						}else{
							mui.alert("网络繁忙,请重试","提示")
						}
						that.disabled=false
					},error:function(){
						mui.alert("网络繁忙,请重试","提示")
						that.disabled=false
					}
				})
			}else{
				that.disabled=false
			}
		})
	})
</script>
</html>